package com.litaomn.fang.hotload.util;

import com.google.common.base.Preconditions;
import com.litaomn.fang.hotload.SO;
import com.tencent.mm.fang.FangHelpers;

import org.apache.commons.lang3.StringUtils;

public class FangUtil {

    public Class getClass(String className) {
        Preconditions.checkNotNull(SO.master, "master不能为空");
        return FangHelpers.findClass(className, SO.master);
    }

    public Object newInstance(String className, Object... args) {
        Preconditions.checkArgument(StringUtils.isNotEmpty(className), "master不能为空");
        return FangHelpers.newInstance(getClass(className), args);
    }

    public void cm(Object object, String methodName, Object... params) {
        FangHelpers.cm(object, methodName, params);
    }

    public void csm(String className, String methodName, Object... params) {
        FangHelpers.csm(getClass(className), methodName, params);
    }

    public void csm(Class clazz, String methodName, Object... params) {
        FangHelpers.csm(clazz, methodName, params);
    }

}
